<template>
  <view class="content">
    <image class="logo" src="/static/logo.png" />
    <view class="text-area">
      <text class="title">{{ title }}</text>
    </view>
    <view class="loading-text" v-if="showLoading">
      <text>{{ countdown }} 秒后跳转...</text>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'

const title = ref('欢迎使用草本应用')
const showLoading = ref(true)
const countdown = ref(3)

onMounted(() => {
  const timer = setInterval(() => {
    countdown.value--
    if (countdown.value <= 0) {
      clearInterval(timer)
      // 使用uni.switchTab进行页面跳转
      uni.switchTab({
        url: '/pages/study/study'
      })
    }
  }, 1000)
})
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}

.loading-text {
  margin-top: 30rpx;
  font-size: 28rpx;
  color: #8f8f94;
}
</style>